home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / asyam.zip / TERM.C < prev   
C/C++ Source or Header  |  1993-06-24  |  3KB  |  107 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4.  
  5. #include "async.h"
  6.  
  7. extern  struct async_portS async_port[4];
  8.  
  9. int     main()
  10. {
  11.     char    ch;
  12.     int     done = 0;
  13.     char    block[1024];
  14.     char    inblock[1024];
  15.     int     ready, i, ii;
  16.  
  17.     window(1,2,80,25);
  18.     clrscr();
  19.  
  20.     switch (async_detect_uart(COM1)) {
  21.         case UART_NONE:
  22.             printf("UART: None\n");
  23.             break;
  24.         case UART_8250:
  25.             printf("UART: 8250\n");
  26.             break;
  27.         case UART_16460:
  28.             printf("UART: 16460\n");
  29.             break;
  30.         case UART_16550:
  31.             printf("UART: 16550\n");
  32.             break;
  33.         case UART_16550A:
  34.             printf("UART: 16550A\n");
  35.             break;
  36.     }
  37.  
  38.     printf("IRQ: %d\n", async_detect_irq(COM1));
  39.  
  40.     open_port(COM1, 38400L, LCR_PNONE, 1, 8);
  41.  
  42.     while (!done) {
  43.         if (async_ready(COM1)) {
  44.             ii = 0;
  45.             ready = async_getblock(COM1, inblock, 1024);
  46.             while (ready--) {
  47.                 cprintf("%c", inblock[ii++]);
  48.             }
  49.         }
  50.  
  51.         if (kbhit()) {
  52.             ch = getch();
  53.             switch (ch) {
  54.                 case 0:
  55.                     switch (getch()) {
  56.                         case 59: //F1
  57.                             set_parity(COM1, LCR_PEVEN);
  58.                             set_wordlength(COM1, 7);
  59.                             break;
  60.                         case 60: //F2
  61.                             set_parity(COM1, LCR_PNONE);
  62.                             set_wordlength(COM1, 8);
  63.                             break;
  64.                         case 61: //F3
  65.                             break;
  66.                         case 62: //F4
  67.                             break;
  68.                         case 63: //F5
  69.                             printf("Baud: 1200\n");
  70.                             set_baudrate(COM1, 1200L);
  71.                             break;
  72.                         case 64: //F6
  73.                             printf("Baud: 2400\n");
  74.                             set_baudrate(COM1, 2400L);
  75.                             break;
  76.                         case 65: //F7
  77.                             printf("Baud: 9600\n");
  78.                             set_baudrate(COM1, 9600L);
  79.                             break;
  80.                         case 66: //F8
  81.                             printf("Baud: 38400\n");
  82.                             set_baudrate(COM1, 38400L);
  83.                             break;
  84.                         case 67: //F9
  85.                             for (i=0; i<1024; i++) {
  86.                                 block[i] = 13;
  87.                             }
  88.                             async_putblock(COM1, block, 1024);
  89.                             break;
  90.                         case 68: //F10
  91.                             done = 1;
  92.                             break;
  93.                     }
  94.                     break;
  95.                 default:
  96.                     async_putch(COM1, ch);
  97.                     break;
  98.             }
  99.         }
  100.     }
  101.  
  102.     close_port(COM1, 0, 0);
  103.  
  104.     return (0);
  105. }
  106.  
  107.